package com.emex.app.web.service;

import com.emex.app.shared.data.Car;
import com.emex.app.shared.data.CarExample;
import com.emex.app.shared.persistance.CarMapper;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Sergey Karavaev
 */
@Service
@Transactional
public class CarService {

    @Autowired
    private CarMapper carMapper;

    public int deleteByPrimaryKey(Integer id) {
        return carMapper.deleteByPrimaryKey(id);
    }

    public Car insert(Car record) {
        carMapper.insert(record);
        return record;
    }

    public List<Car> selectByExample(CarExample carExample) {
        return carMapper.selectByExample(carExample);
    }

    public Car selectByPrimaryKey(Integer id) {
        return carMapper.selectByPrimaryKey(id);
    }

    public Car updateByPrimaryKey(Car record) {
        carMapper.updateByPrimaryKey(record);
        return record;
    }

    public List<Car> getAllCarsByClientId(Integer id) {
        CarExample carExample = new CarExample();
        carExample.createCriteria().andClientIdEqualTo(id);
        return selectByExample(carExample);
    }
}
